#namespace("com.htwy.core.model.Dictionary")
  #sql("findByCondition")
    SELECT uuid, label, code, parent, serial, creator, createTime, mender, modifyTime, deletedBy, deletedMarker, deleteTime
    FROM ht_sys_dictionary
    #WHERE()
      #if(uuid)
        uuid = #para(uuid)
      #end
      #if(label)
        AND label = #para(label)
      #end
      #if(code)
        AND code = #para(code)
      #end
      #if(parent)
        #if(parent == "#")
          AND parent IS NULL
        #else
          AND parent = #para(parent)
        #end
      #end
      #if(serial)
        AND serial = #para(serial)
      #end
      #if(creator)
        AND creator = #para(creator)
      #end
      #if(createTime)
        AND createTime = #para(createTime)
      #end
      #if(mender)
        AND mender = #para(mender)
      #end
      #if(modifyTime)
        AND modifyTime = #para(modifyTime)
      #end
      #if(deletedBy)
        AND deletedBy = #para(deletedBy)
      #end
      #if(deletedMarker)
        AND deletedMarker = #para(deletedMarker)
      #end
      #if(deleteTime)
        AND deleteTime = #para(deleteTime)
      #end
    #end
    ORDER BY serial asc
  #end

  #sql("deleteByPks")
    DELETE FROM ht_sys_dictionary
    #WHERE()
      #if(pks != null && pks.length > 0)
        #if(pks.length>1)
          uuid in (
          #for(tempId : pks)
            #if(for.first)
              #para(tempId)
            #else
              , #para(tempId)
            #end
          #end
          )
        #else
          uuid = #para(pks[0])
        #end
      #end
    #end
  #end

  #sql("findByParentCodes")
    SELECT c.label label, c.code code, p.code parentCode
    FROM ht_sys_dictionary c
    INNER JOIN ht_sys_dictionary p
    ON c.parent = p.uuid
    #WHERE()
      #if(codes != null && codes.length > 0)
        #if(codes.length>1)
          p.code in (
          #for(temp : codes)
            #if(for.first)
              #para(temp)
            #else
              , #para(temp)
            #end
          #end
          )
        #else
          p.code = #para(codes[0])
        #end
      #end
    #end
    ORDER BY p.code asc, c.serial asc
  #end

  #sql("deleteByParent")
    DELETE FROM ht_sys_dictionary
    WHERE parent = #para(parent)
  #end
#end